<template>
  <!--ASN明细-->
  <div id="AsnDetails">
    <v-details :detailData="data.detailData" :inputConfig="inputConfig" :rules="rules" @pop="setdata"></v-details>
  </div>
</template>

<script>
import details from 'commons/Detail'
import baseMixin from '@/mixins/BaseMixin'

export default {
  name: 'AsnDetails',
  mixins: [baseMixin],
  props: {
    data: {
      type: Object
    }
  },
  data() {
    return {
      inputConfig: [
        [
          {
            type: 'input',
            label: this.$t('outbound.userlinenumber'),
            disabled: true,
            props: 'polinenumber'
          },
          {
            type: 'input',
            label: this.$t('in.pokey1'),
            disabled: true,
            props: 'pokey'
          },
          {
            type: 'table',
            label: this.$t('config.sku'),
            disabled: !this.data.detailData.storerkey,
            props: 'sku',
            filterKey: ['descr', 'sku'],
            tableConfig: [
              {
                label: this.$t('config.sku'),
                prop: 'sku',
                input: 'input'
              },
              { label: this.$t('common.desc'), prop: 'descr', input: 'input' },
              {
                label: this.$t('config.shipper'),
                prop: 'storerkey',
                input: 'input'
              },
              {
                label: this.$t('config.packaging'),
                prop: 'packkey',
                input: 'input'
              },
              {
                label: this.$t('config.boxGroup'),
                prop: 'cartongroup',
                input: 'select',
                options: this.getOptions('queryCartonizationDropDown')
              },
              {
                label: this.$t('config.allocaStrategy'),
                prop: 'strategykey',
                input: 'select',
                options: this.getOptions('queryAllocatestrategyDropDown')
              },
              {
                label: this.$t('config.putawayStrategy'),
                prop: 'putawaystrategykey',
                input: 'select',
                disabled: false,
                options: this.getOptions('queryPutawaystrategyDropDown')
              },
              {
                label: this.$t('config.batchValidate'),
                prop: 'lottablevalidationkey',
                input: 'select',
                options: this.getOptions('queryLottablevalidationDropDown')
              },
              {
                label: this.$t('config.area'),
                prop: 'putawayzone',
                input: 'select',
                options: this.getOptions('queryPutawayzoneDropDown')
              }
            ],
           filterUrl: `fuzzyQuerySkuByItemNumberAndName/undefined`,
          url: `querySkuOfStorerkey/?/${this.$store.state.wms}/undefined`,
          },
          {
            type: 'input',
            label: this.$t('common.desc'),
            disabled: true,
            props: 'descr'
          },
          {
            type: 'input',
            label: this.$t('config.packaging'),
            disabled: true,
            props: 'packkey'
          },
          {
            type: 'input',
            label: this.$t('in.qtyordered'),
            disabled: true,
            props: 'qtyordered'
          },
          {
            type: 'select',
            label: this.$t('config.measureUnit'),
            disabled: true,
            props: 'uom',
            options: []
          }
        ],
        [
          {
            type: 'select',
            label: this.$t('common.status'),
            disabled: true,
            props: 'status',
            options: this.getOptions('codelkup/RECSTATUS')
          },
          {
            type: 'input',
            label: this.$t('in.qtyreceived'),
            disabled: true,
            props: 'qtyreceived'
          },
          {
            type: 'input',
            label: this.$t('in.rtxStylekey'),
            disabled: true,
            props: 'rtxStylekey'
          }
        ],
        [
          {
            type: 'select',
            label: this.$t('in.qcrequired'),
            disabled: true,
            props: 'qcrequired',
            options: this.getOptions('codelkup/YESNO')
          },
          {
            type: 'select',
            label: this.$t('in.qcautoadjust'),
            props: 'qcautoadjust',
            options: this.getOptions('codelkup/YESNO')
          }
        ]
      ],
      rules: {
        polinenumber: [{ required: true, trigger: 'blur' }],
        sku: [{ required: true, trigger: 'blur' }],
        descr: [{ required: true, trigger: 'blur' }],
        packkey: [{ required: true, trigger: 'blur' }],
        uom: [{ required: true, trigger: 'blur' }]
      }
    }
  },
  methods: {
    setdata(data, id, close) {
      this.data.detailData.sku = data.sku
      this.data.detailData.descr = data.descr
      this.data.detailData.storerkey = data.storerkey
      this.data.detailData.packkey = data.packkey
      close(false)
    }
  },
  mounted() {},
  watch: {
    'data.detailData.packkey': {
      handler(data) {
        this.inputConfig[0].forEach(item => {
          if (item.props == 'uom') {
            item.options = this.getOptions(`codelkup/defaultUom/${data}`)
          }
        })
      },
      immediate: true,
      deep: true
    },
    '$parent.$parent.$refs.detail.detailData.storerkey'(data) {
      this.inputConfig[0].forEach(item => {
        if (item.props == 'sku') {
          item.filterUrl = "fuzzyQuerySkuByItemNumberAndName/" + data;
            item.url = "querySkuOfStorerkey/?/wmwhse1/" + data;
        }
      })
    },
    '$parent.$parent.$refs.detail.detailData.pokey': {
      handler(data) {
        this.data.detailData.pokey = data
      },
      immediate: true,
      deep: true
    }
  },
  components: {
    'v-details': details
  }
}
</script>

<style scoped>
</style>
